package 每日一题;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class 猜数字游戏 {
    public String getHint(String secret, String guess) {
        char[] se = secret.toCharArray();
        char[] gu = guess.toCharArray();
        int bulls = 0;
        int cows = 0;
        for (int i = 0; i < se.length; i++) {
            if (i>=gu.length)
                break;
            if (se[i]==gu[i]){
                bulls++;
                se[i] = ' ';
                gu[i] = ' ';
            }
        }
        List<Character> chars = new ArrayList<>();
        for (int i = 0; i < se.length; i++) {
            chars.add(se[i]);
        }
        System.out.println(chars.toString());
        for (int i = 0; i < gu.length; i++) {
            if (gu[i]==' ')
                continue;
            if (chars.contains(gu[i])){
                cows++;
                chars.remove(chars.indexOf(gu[i]));
            }
        }
        return bulls+"A"+cows+"B";
    }
}
